package com.three.crm.page;


import android.content.Context;
import android.os.Bundle;
import android.view.View;

import com.three.crm.R;
import com.three.crm.base.BaseActivity;
import com.three.crm.constant.AppConstant;
import com.yc.video.player.VideoPlayer;
import com.yc.video.ui.view.BasisVideoController;

/**
 * 播放视频
 * created by lqd on 2023-12-12.
 */
public class VideoPlayActivity extends BaseActivity {

    private String videoUrl = "";
    private VideoPlayer mVideoPlayer;

    @Override
    protected void initParms(Bundle bundle) {
        if (bundle != null) {
            videoUrl = bundle.getString(AppConstant.VIDEO_PATH);
        }
    }

    @Override
    protected int bindLayout() {
        return R.layout.activity_video_play;
    }

    @Override
    protected void initViews(View view, Bundle savedInstanceState) {
        mVideoPlayer = $(R.id.video_player);
        //创建基础视频播放器，一般播放器的功能
        BasisVideoController controller = new BasisVideoController(this);
        //设置控制器
        mVideoPlayer.setController(controller);
        //设置视频播放链接地址
        mVideoPlayer.setUrl(videoUrl);
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void widgetClick(View v) {

    }

    @Override
    protected void onResume() {
        super.onResume();
        mVideoPlayer.resume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mVideoPlayer.pause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mVideoPlayer.release();
    }

    @Override
    public void initData(Context mContext) {
        if (videoUrl != null && videoUrl != "") {
            mVideoPlayer.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mVideoPlayer.start();
                }
            },300);
        }
    }
}